﻿var x = 50,y = 60;
var xin = true, yin = true;
var step = 1;
var delay =20;
var obj=document.getElementById("moveads");
function float() 
{
	var L=T=0;
	var R=(typeof(document.documentElement.scrollTop)=="number" ? document.documentElement.clientWidth :  document.body.clientWidth)-obj.offsetWidth;
	var B=(typeof(document.documentElement.scrollTop)=="number" ? document.documentElement.clientHeight :  document.body.clientHeight)-obj.offsetHeight;
	
	obj.style.left = (x +(typeof(document.documentElement.scrollLeft)=="number" ? document.documentElement.scrollLeft :  document.body.scrollLeft )) + "px";
	obj.style.top = (y + (typeof(document.documentElement.scrollTop)=="number" ? document.documentElement.scrollTop :  document.body.scrollTop )) + "px";
	x = x + step*(xin?1:-1);
	if (x < L) { xin = true; x = L;}
	if (x > R){ xin = false; x = R;};
	y = y + step * (yin?1:-1);
	if (y < T) { yin = true; y = T;}
	if (y > B) { yin = false; y = B;}
};
var itl= setInterval("float()", delay);
obj.onmouseover=function(){clearInterval(itl);};
obj.onmouseout=function(){itl=setInterval("float()", delay);};